<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">

<f:metadata>  
    <f:viewParam name="idpacchetto" value="#{packPresBean.pacchetto.descrizione}" />  
</f:metadata>

<h:head>
<h:outputStylesheet library="css" name="default.css" target="head" />
	<title>Visualizza dettagli pacchetto</title>
</h:head>
<h:body >
#{packPresBean.onLoadFormDettagliPacchetto()}
<h:form>
<p:toolbar style="heigh:35px; margin-bottom:25px" id="tb">
		<p:toolbarGroup align="left" style="margin-top:5px; margin-left:10px" id="tools">
		Utente #{userBean.name} <p:separator/> #{userBean.mail}
		
		</p:toolbarGroup>
		<p:toolbarGroup align="right">	
		<p:button value="Indietro" outcome="show_pacchetti.xhtml" icon="ui-icon-carat-1-w" />
			<p:menuButton value="Opzioni">
					<p:menuitem value="Home" url="index.xhtml" icon="ui-icon-home" />
					<p:menuitem value="Visualizza Carrello" outcome="show_carrello.xhtml" icon="ui-icon-cart" />
					<p:menuitem value="Mostra Prenotazioni" outcome="show_prenotati.xhtml" icon="ui-icon-tag" />
					<p:menuitem value="Visualizza Pacchetti" outcome="show_pacchetti.xhtml" icon="ui-icon-suitcase" />
			</p:menuButton>
		<p:separator/>
		<p:commandButton action="#{logBean.logout}" value="Logout" icon="ui-icon-power" />
		</p:toolbarGroup>
	</p:toolbar>
	<p:sticky target="tb" />
	</h:form>
<h:form id="form">
	<h:message for="savePacchetto" errorClass="error" id="save_pacchetto_err"/>
				<p:growl id="messages" showDetail="true"/> 
				
                <h:outputText id="modelNo" value="#{packPresBean.pacchettoInCarrello.IDPacchetto}" /> 
                <p:dataTable id="Hotel" var="pkHotel" value="#{packPresBean.pacchettoInCarrello.hotels}" editable="true" editMode="cell" >  
                
                <p:ajax event="cellEdit" listener="#{packPresBean.onCellEdit}" update=":form:messages" /> 
                
			        <p:column headerText="ID">
			            <h:outputText value="#{pkHotel.hotel.ID}" />
			        </p:column>
			        <p:column headerText="nome">  
			            <h:outputText value="#{pkHotel.hotel.nome}" />
			        </p:column>
			      
			        <p:column headerText="Numero Persone">
				        <p:cellEditor>
			                <f:facet name="output"><h:outputText value="#{pkHotel.numeroPersone}" /></f:facet>
			                <f:facet name="input"><p:inputText value="#{pkHotel.numeroPersone}" style="width:96%" /></f:facet>
			            </p:cellEditor>
			        </p:column>
			        <p:column headerText="Data CheckIN">
			        <p:calendar value="#{pkHotel.checkIN}" showButtonPanel="true"/>
			        </p:column>
			        <p:column headerText="Data CheckOUT">
			        	<p:calendar value="#{pkHotel.checkOUT}" showButtonPanel="true"/>
			        </p:column>
			        <p:column >
			        	<p:commandButton value="Delete" action="#{packPresBean.delete}" update=":form:Hotel">
			        			<f:setPropertyActionListener value="#{pkHotel}" target="#{packPresBean.cancellaHotel}" />
			        	</p:commandButton>
			        </p:column>
			    </p:dataTable>
			   
				   <!-- Aggiungi hotel -->
				  <p:accordionPanel>
   						<p:tab title="Aggiungi Hotel">
						   <p:dataTable var="hotel" value="#{packPresBean.allHotel}" rowKey="#{hotel.ID}" paginator="true" rows="10"  
			                 selection="#{packPresBean.aggiungiHotel}" selectionMode="single" filteredValue="#{packPresBean.filteredHotel}" id="AllHotelTable" >  
			  
						        <!-- <p:ajax event="rowSelect" update=":form:display" oncomplete="carDialog.show()" />   -->
						  
						        <f:facet name="header">
						            List of Hotels
						            <p:commandButton value="Aggiungi a lista" action="#{packPresBean.aggiungiHotel}" update=":form:Hotel" ></p:commandButton>
						        </f:facet>
						  
						        <p:column headerText="Nome" sortBy="nome" filterBy="nome" id="nome">  
						            #{hotel.nome}
						        </p:column>
						        
						        <p:column headerText="Stato" sortBy="localita.stato" filterBy="localita.stato" id="stato">  
						            #{hotel.localita.stato}
						        </p:column>
						  
						        <p:column headerText="Città" sortBy="localita.nome" filterBy="localita.nome" id="citta">  
						            #{hotel.localita.nome}
						        </p:column>
						  
						        <p:column headerText="Via" sortBy="via" filterBy="via" id="via">  
						            #{hotel.via}
						        </p:column>
			    		</p:dataTable>
			    	</p:tab>
			    </p:accordionPanel>
			    
			    
			    <!-- Per il TOUR!!! -->
			     <p:dataTable id="Tour" var="pkTour" value="#{packPresBean.pacchettoInCarrello.tours}" editable="true" editMode="cell" >  
                    
			        <p:column headerText="ID">  
			            <h:outputText value="#{pkTour.tour.ID}" />  
			        </p:column>  
			        <p:column headerText="nome">  
			            <h:outputText value="#{pkTour.tour.descrizione}" />  
			        </p:column>   
			        
			        <p:column headerText="Numero Persone">
			        <p:cellEditor>
			                <f:facet name="output"><h:outputText value="#{pkTour.numeroPersone}" /></f:facet>
			                <f:facet name="input"><p:inputText value="#{pkTour.numeroPersone}" style="width:96%" id="nPersoneTour"/></f:facet>
			            </p:cellEditor>
				        <!-- <p:cellEditor>  
			                <f:facet name="output"><h:outputText value="#{pkTour.numeroPersone}" /></f:facet>  
			                <f:facet name="input"><p:inputText value="#{pkTour.numeroPersone}" style="width:96%" /></f:facet>  
			            </p:cellEditor>   -->
			        </p:column>
			        <p:column headerText="Data ">
			        <p:calendar value="#{pkTour.data}" showButtonPanel="true"/>  
			        </p:column>
			        <p:column >
			        	<p:commandButton value="Delete" action="#{packPresBean.deleteTour}" update=":form:Tour">
			        			<f:setPropertyActionListener value="#{pkTour}" target="#{packPresBean.cancellaTour}" />
			        	</p:commandButton>  
			        </p:column>
			    </p:dataTable> 
			   
				   <!-- Aggiungi tour -->
				  <p:accordionPanel>  
   						<p:tab title="Aggiungi Tour"> 
						   <p:dataTable var="tour" value="#{packPresBean.allTour}" rowKey="#{tour.ID}" paginator="true" rows="10"  
			                 selection="#{packPresBean.aggiungiTour}" selectionMode="single" filteredValue="#{packPresBean.filteredTour}" id="AllHotelTable" >  
			  
						        <!-- <p:ajax event="rowSelect" update=":form:display" oncomplete="carDialog.show()" />   -->
						  
						        <f:facet name="header">  
						            List of Tour
						            <p:commandButton value="Aggiungi a lista" action="#{packPresBean.aggiungiTour}" update=":form:Tour" ></p:commandButton>
						        </f:facet>

						        <p:column headerText="Descrizione" sortBy="descrizione" filterBy="descrizione" id="nome">  
						            #{tour.descrizione}  
						        </p:column>  
						        
						        <p:column headerText="Stato" sortBy="localita.stato" filterBy="localita.stato" id="stato">  
						            #{tour.localita.stato}  
						        </p:column>
						  
						        <p:column headerText="Città" sortBy="localita.nome" filterBy="localita.nome" id="citta">  
						            #{tour.localita.nome}  
						        </p:column>  
						   
			    		</p:dataTable>  
			    	</p:tab>
			    </p:accordionPanel>
			    
			    <!-- Per il Volo!!! -->
			     <p:dataTable id="Volo" var="pkVolo" value="#{packPresBean.pacchettoInCarrello.voli}" editable="true" editMode="cell" >  
             
			        <p:column headerText="Da aeroporto">  
			            <h:outputText value="#{pkVolo.trattaVolo.daAeroporto.name}" />  
			        </p:column>  
			        <p:column headerText="A aeroporto">  
			            <h:outputText value="#{pkVolo.trattaVolo.aAeroporto.name}" />  
			        </p:column>    
			        <p:column headerText="A aeroporto">  
			            <h:outputText value="#{pkVolo.trattaVolo.compagnia.nome}" />  
			        </p:column>  
			        <p:column headerText="NPersoneTour">
				        <p:cellEditor>  
			                <f:facet name="output"><h:outputText value="#{pkVolo.numeroPersone}" /></f:facet>  
			                <f:facet name="input"><p:inputText value="#{pkVolo.numeroPersone}" style="width:96%" id="numPersoneVolo" label="NPersoneTour"/></f:facet>  
			            </p:cellEditor>  
			        </p:column> 
			        <p:column headerText="Data ">
			        <p:calendar value="#{pkVolo.data}" showButtonPanel="true"/>  
			        </p:column>
			        <p:column >
			        	<p:commandButton value="Delete" action="#{packPresBean.deleteAeroporto}" update=":form:Volo">
			        			<f:setPropertyActionListener value="#{pkVolo}" target="#{packPresBean.cancellaVolo}" />
			        	</p:commandButton>  
			        </p:column>
			    </p:dataTable> 
			    
			     <!-- Aggiungi Volo -->
				  <p:accordionPanel>  
   						<p:tab title="Aggiungi Volo"> 
						   <p:dataTable var="volo" value="#{packPresBean.allVoli}" rowKey="#{volo.ID}" paginator="true" rows="10"  
			                 selection="#{packPresBean.aggiungivolo}" selectionMode="single" filteredValue="#{packPresBean.filteredVoli}" id="AllHotelTable" >  

						        <f:facet name="header">  
						            List of Voli
						            <p:commandButton value="Aggiungi a lista" action="#{packPresBean.aggiungiVolo}" update=":form:Volo" ></p:commandButton>
						        </f:facet>  
						  
						        <p:column headerText="Da aeroporto" sortBy="daAeroporto.name" filterBy="daAeroporto.name" id="aAeroporto">  
						            #{volo.daAeroporto.name}  
						        </p:column>  
						        
						         <p:column headerText="Da aeroporto" sortBy="aAeroporto.name" filterBy="aAeroporto.name" id="daAeroporto">  
						            #{volo.aAeroporto.name}  
						        </p:column> 
						        
						        <p:column headerText="Compagnia" sortBy="compagnia.nome" filterBy="compagnia.nome" id="compagnia">  
						            #{volo.compagnia.nome}  
						        </p:column>
						  
						   
			    		</p:dataTable>  
			    	</p:tab>
			    </p:accordionPanel>
			    
				<p:commandButton value="Submit" action="#{packPresBean.check}" type="submit"></p:commandButton>
				<p:messages id="mex" showDetail="true" autoUpdate="true" closable="true" />
</h:form>
</h:body>
</html>